// 为 Styled Component 提供 Antd 类型支持
import { theme } from 'antd'
import type { ThemeConfig } from 'antd/es/config-provider/context'
import type { AliasToken } from 'antd/lib/theme/interface'

import componentsOverrides from '@/theme/overrides'

// 添加自动补全
type ThemeType = Partial<
  AliasToken & {
    // 还有其他的自定义参数
  }
>
declare module 'styled-components' {
  // eslint-disable-next-line @typescript-eslint/no-empty-interface
  interface DefaultTheme extends ThemeType {}
}

const { getDesignToken } = theme

// antd Token
const antdOptions: ThemeConfig = {
  token: {
    // colorPrimary: '#4fb93f',
    screenXXL: 1920,
    screenXXLMin: 1920,
    screenXLMax: 1919,
    borderRadius: 0,
    fontFamily:
      '-apple-system, BlinkMacSystemFont, Segoe UI, PingFang SC, Hiragino Sans GB, Microsoft YaHei, Helvetica Neue, Helvetica, Arial, sans-serif',
  },
}
const themeToken = getDesignToken(antdOptions)

// 根据主题变量修改 Antd 组件的样式
const customisedComponents = componentsOverrides(themeToken)

// Antd 主题配置
const antdConfig: ThemeConfig = {
  ...antdOptions,
  components: customisedComponents,
  hashed: false,
  cssVar: true,
}

export { themeToken, antdConfig }
